<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>二手交易平台</title>
  <link rel="stylesheet" type="text/css" href="/ssm/consumer/res/static/css/main.css">
  <link rel="stylesheet" type="text/css" href="/ssm/consumer/res/layui/css/layui.css">
  <script type="text/javascript" src="/ssm/consumer/res/layui/layui.js"></script>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <style type="text/css">
  	.userNotLogin{
  		display: none;
  	}
  </style>
</head>
<body>

  <div class="site-nav-bg">
    <div class="site-nav w1200">
      <p class="sn-back-home">
        <i class="layui-icon layui-icon-home"></i>
        <a href="index.html">首页</a>
      </p>
      <div class="sn-quick-menu">
        	<div class="userLogin">
        		<div class="login"><a href="/ssm/consumer/login.html">登录</a></div>
        		<div class="login"><a href="/ssm/consumer/register.html">注册</a></div>
        	</div>
        	<div class="userNotLogin">
        		<div class="login"><a href="/ssm/consumer/userInfo.html" id="username">用户名</a></div>
        		<div class="login"><a href="JavaScript:loginOut();">退出</a></div>
        		<div class="login"><a href="/ssm/consumer/myOrder.html">我的订单</a></div>
        		<div class="sp-cart"><a href="/ssm/consumer/shopcart.html">购物车</a></div>
        	</div>
      </div>
    </div>
  </div>



  <div class="header">
    <div class="headerLayout w1200">
      <div class="headerCon">
        <h1 class="mallLogo">
           <a href="/ssm/consumer/index.html" title="二手交易平台">
            <img src="/ssm/consumer/res/static/img/logo.png">
          </a>
        </h1>
        <div class="mallSearch">
          <form action="" class="layui-form" novalidate>
            <input type="text" id="keyword" name="title" required  lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入需要的商品">
            <button class="layui-btn" id="searchbutton" lay-filter="formDemo" onclick="return false">
                <i class="layui-icon layui-icon-search"></i>
            </button>
            <input type="hidden" name="" value="">
          </form>
        </div>
      </div>
    </div>
  </div>


  <div class="content content-nav-base commodity-content">
    <div class="main-nav">
      <div class="inner-cont0">
        <div class="inner-cont1 w1200">
          <div class="inner-cont2">
            <a  class="active">欢迎光临<span id="companyName"></span>的店铺</a>
          </div>
        </div>
      </div>
    </div>
    <div class="commod-cont-wrap">
      <div class="commod-cont w1200 layui-clear">
        <div class="left-nav">
          <div class="list-box">
            <div class="preview-wrap">
        	 <div class="layui-clear">
		      	<div style="width:220px;height:300px;;background-color: #f6f6f6;float: left;">
		        		<h3 style="text-align: center;line-height: 30px;">卖家信息</h3>
		        		<hr>
		        		<div style="text-align: center;margin-left: 80px;">
		        			<img src="https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3187703603,4093680061&fm=26&gp=0.jpg" style="display: block; left: 265.114px; top: -10px; width: 63.75px; height: 60px;vertical-align: middle;border: 1px solid #ccc;border-radius: 30px;"/>
		        		</div>
		        		<div style="text-align: center;margin-left: -30px;">
		        			 <p class="address-box" style="    line-height: 40px;
		    padding-left: 34px;text-align:center;
		    color: #888888;"><span>店铺成交量： </span><strong id="company_buynum">暂无记录</strong> </p>
		               <p class="address-box" style="    line-height: 40px;
		    padding-left: 34px;text-align:center;
		    color: #888888;"><span>消费好评度：</span><strong id="company_score">暂无记录</strong> </p>
		     <p class="address-box" style="    line-height: 40px;
		    padding-left: 34px;text-align:center;
		    color: #888888;"><span>联系方式：</span><strong id="company_phone">暂无记录</strong> </p>
		     <p class="address-box" style="    line-height: 40px;
		    padding-left: 34px;text-align:center;
		    color: #888888;"><span>联系地址：</span><strong id="company_address">暂无记录</strong> </p>
		     <p class="address-box" style="    line-height: 40px;margin-bottom:10px;
		    padding-left: 34px;text-align:center;
		    color: #888888;"><a style="color: blue;" id="退出店铺" href="index.html">退出店铺</a> </p>
		        		</div>
		        		<br/>
		       	</div>
		      </div>
        </div>
          </div>
        </div>
        <div class="right-cont-wrap">
          <div class="right-cont">
           <!--  <div class="sort layui-clear">
              <a class="active" href="javascript:;" event = 'volume'>销量</a>
              <a href="javascript:;" event = 'price'>价格</a>
              <a href="javascript:;" event = 'newprod'>新品</a>
              <a href="javascript:;" event = 'collection'>收藏</a>
            </div> -->
            <div class="prod-number">
             <!--  <span>200个</span> -->
            </div>
            <div class="cont-list layui-clear" id="list-cont">
             
             
            </div>
           
            <div id="demo0" style="text-align: center;"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
<script type="text/javascript" src="/ssm/consumer/js/jquery-1.4.3.min.js"></script>
<script type="text/javascript">

$("#searchbutton").click(function Search(){
	location.href="/ssm/consumer/index.html?pname="+$("#keyword").val();
	return false;
})

$("#keyword").val(getQueryString('pname'));

var info;
getUserInfo();
function  getUserInfo(){
    $.ajax({
        url:"/ssm/consumer/loginInfo.do",
        type:"POST",
        dataType:"json",
        success:function(data){
        	info = data.body
           if(info!=null){
        	   $(".userLogin").hide();
        	   $("#username").text(info.real_name);
        	   $(".userNotLogin").show();
           }else{
           }
        } 
    })
 }
 
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return decodeURI(r[2]); return null;
} 
//获取商品列表
getProductList();
function getProductList(){
	var postData = {
			page:1,
			limit:100,
			status:1,
			consumer_id:getQueryString("id"),
			cid:getQueryString("cid"),
			pname:getQueryString('pname')
	}
	$.post('/ssm/product/queryList.do',postData,function(data){
		console.log(data);
		for(var idx in data.body.list){
			var productItem = data.body.list[idx];
			var item = ' <div class="item">';
			item+='<div class="img">';
			item+='<a href="/ssm/consumer/details.html?pid='+productItem.pid+'"><img style="width:280px;height:280px;" src="'+productItem.imgurl.split(",")[0]+'"></a>';
			item+='</div>';
			item+='<div class="text">';
			item+='<p class="title">'+productItem.pname+'</p>';
			item+='<p class="price">';
			item+='<span class="pri">￥'+productItem.estoreprice+'</span>';
			item+='<a class="nub" href="/ssm/consumer/details.html?pid='+productItem.pid+'">查看详情</a>';
			item+='</p>';
			item+='</div>';
			item+='</div>';
			
			/* var item = '<div class="'+(idx % 3 != 2?'product_box':'product_box no_margin_right')+'">';
			item+='<a href="/ssm/consumer/productDetail.html?pid='+productItem.pid+'">';
			item+='<img src="'+productItem.imgurl+'" width="140" height="180" alt="" title="'+productItem.pname+'"/>';
			item+='</a>';
			item+='<h3>'+productItem.pname+'</h3>';
			item+='<p class="product_price">￥ '+productItem.estoreprice+'</p>';
			item+='<i class="fa fa-shopping-cart"></i><a href="javascript:addCart(\''+productItem.pid+'\')">加入购物车</a>';
        	item+=' <a href="/ssm/consumer/productDetail.html?pid='+productItem.pid+'">查看详情</a>';
        	item+='</div>';
        	if(idx%3==3){
        		item+='<div class="cleaner"></div>';
        	} */
			$("#list-cont").append(item);
		}
		if(data.body.list.length==0){
			$("#list-cont").append("<h1 style='text-align:center;'>没有找到相关的商品</h1>");
		}
		
	})
	
	
}

queryCompany(getQueryString("id"));
function queryCompany(consumerId){
	  var postData={
			  consumerId:consumerId,
      }
      $.post('/ssm/order/queryCompany.do',postData,function(data){
    	  	if(data.body){
    	  	$("#company_buynum").text(data.body.buynum);
    		$("#company_score").text(data.body.socre);
    		$("#company_phone").text(data.body.cellphone);
    		$("#company_address").text(data.body.address);
    		$("#companyName").text(data.body.real_name);
    		
    	  	}
      })
	  
}

function loginOut(){
	$.post('/ssm/consumer/logout.do',function(){
		
		location.href="/ssm/consumer/login.html";
	})
}
</script>


</body>
</html>